<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>属性选择器</title>
  <style>
    /* 
    属性选择器
    
     */
    * {
      margin: 0;
      padding: 0;
    }

    /* 拥有某个属性 */
    [src] {
      width: 100%;
    }

    /* =等于某个属性 */
    [alt="girl1"] {
      width: 50%;
    }

    /* * 包含属性 */
    [alt*="girl"] {
      width: 75%;
    }

    /* ~以~包含某个属性，但是要以空白进行分割 */
    [alt~="l"] {
      height: 100px;
    }

    [alt^="g"] {
      background-color: #fff;
    }

    [alt$="1"] {
      text-align: center;
    }

    /* alt属性值恰好等于girl1 或者 以单词girl1开头且后面紧跟着连字符-的元素*/
    [alt |="girl1"] {
      margin-top: 10px;
    }

    [alt~="girl1"] {
      padding: 10px;
    }
  </style>
</head>

<body>
  <div><img src="../../img/0.jpg" alt="girl1"></div>
  <div><img src="../../img/1.jpg" alt="girl2"></div>
  <div><img src="../../img/2.jpg" alt="gir l 3"></div>
  <div><img src="../../img/3.jpg" alt="l ake 1"></div>
  <div><img src="../../img/4.jpg" alt="girl1-10"></div>
  <div><img src="../../img/5.jpg" alt="girl1 10"></div>
</body>

</html>